//
//  OtherEventReportController.m
//  Runone
//
//  Created by runone02 on 16/11/10.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "OtherEventReportController.h"
#import "RequestHelper.h"
#import "MJExtension.h"
#import "ParModel.h"
#import "EventBaseInfo.h"
#import "MapPointViewController.h"
#import "CityDirectionController.h"
#import "TableOperation.h"
#import "PileInfo.h"
#import "CommonUtilityjudge.h"
#import "PromptUtil.h"
#import "UITextField+ToolBar.h"
#import "UITextView+ToolBar.h"
#import "SGImagePickerController.h"
//#import "UIColor+ZXLazy.h"
#import "SVProgressHUD.h"
#import "BCNetAPIClient.h"
#import "LittleVideoViewController.h"
#import "ROActionSheet.h"
#import "ChooseLineTableViewController.h"
#import "ROImagePickViewController.h"
#import "YZInputView.h"
#import "AJPhotoPickerViewController.h"
#import "AJPhotoBrowserViewController.h"
#import "OtherEventMainLineViewController.h"
#import "HighWayRoadRecordDirectionInfoModel.h"

@interface OtherEventReportController () <UIPopoverPresentationControllerDelegate,UITextViewDelegate,UIAlertViewDelegate,UITextFieldDelegate,LittleVideoDelegate,AJPhotoPickerProtocol,AJPhotoBrowserDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>{

    AVPlayer *_player;
    AVPlayerItem *_playItem;
    AVPlayerLayer *_playerLayer;
    AVPlayerLayer *_fullPlayer;
    BOOL _isPlaying;
}
@property(nonatomic)NSInteger code;
@property (weak, nonatomic) IBOutlet UIScrollView *backScrollView;
//输入控件
@property (weak, nonatomic) IBOutlet UIView *containerView;
@property (weak, nonatomic) IBOutlet UIView *descriptionView;
@property (weak, nonatomic) IBOutlet UITextField   *BeginPirTF;
@property (weak, nonatomic) IBOutlet UITextField   *DistanceTF;
@property (weak, nonatomic) IBOutlet UITextField   *carDirectorTF;
@property(nonatomic,strong) MapPointViewController *map;
@property (weak, nonatomic) IBOutlet UIButton      *mapBtn;
@property (weak, nonatomic) IBOutlet YZInputView   *DescriptionTV;
@property (weak, nonatomic) IBOutlet UITextField   *LineTF;
@property (weak, nonatomic) IBOutlet UIView        *imagesScrollView;
@property (weak, nonatomic) IBOutlet UIScrollView  *scrollView;
@property (weak, nonatomic) IBOutlet UIView        *videoView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *desTVHeight; //
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *descriptionVheight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *containerViewHeight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *btnViewTop;
@property (assign, nonatomic) CGFloat textHeight;
//相关视图
@property(nonatomic,strong)CityDirectionController        *citypop;
@property(nonatomic,strong)OtherEventMainLineViewController  *lineVC;
@property(nonatomic,strong)EventBaseInfo                  *info;
@property(nonatomic,copy)  NSString     *lo;
@property(nonatomic,copy)NSString     *la;
@property(nonatomic,strong)PromptUtil *PromptUtil;
//选择图片
@property(nonatomic,strong)   UIImage          *img;
@property(nonatomic,strong)   UIImageView      *iv;
@property(nonatomic,strong)   NSMutableArray   *imageArray;
@property(nonatomic,strong)   UIAlertView      *resultAlert;
@property (nonatomic, strong) ROActionSheet *sheet;
@property(nonatomic,strong)   NSMutableArray   *loadImageArr;
@property (nonatomic,strong) NSURL *videoUrl;
@property (strong, nonatomic) NSMutableArray *photos;
@property (strong, nonatomic) HighwayMergeRoadRecordModel *currentModel;//当前选中的道路模型
@property (nonatomic, copy) NSString *directionUID;
@end

@implementation OtherEventReportController

- (NSMutableArray *)photos {
    if (_photos == nil) {
        _photos = [NSMutableArray array];
    }
    return _photos;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    _backScrollView.bounces = NO;
    [self configCameraBtn];
    _carDirectorTF.delegate=self;
    UILabel *label      = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
    label.text          = @"其他事件上报";
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor     = [UIColor whiteColor];
    self.navigationItem.titleView=label;
    _PromptUtil=[[PromptUtil alloc] init];
    _info=[[EventBaseInfo alloc] init];
    _info.IncidentType=@"10";
    __weak typeof(self) _weakSelf=self;
    _map=[[MapPointViewController alloc] init];
    _map.FloatBlock=^(CGFloat la,CGFloat lo){
        _weakSelf.info.Latitude = la;
        _weakSelf.info.Longitude = lo;
    };

    _currentModel = [[HighwayMergeRoadRecordModel alloc] init];
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

-(void)configCameraBtn {
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"提 交" style:UIBarButtonItemStylePlain target:self action:@selector(report)];
}

- (BOOL) isNumber:(NSString *)text;
{
    NSString *regex =@"[0-9]*";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    if (![pred evaluateWithObject:text]) {
        NSLog(@"不是");
        return YES;
    }
    NSLog(@"是");
    return NO;
}

-(void)resultMessage:(NSString *)result {
    _resultAlert=[[UIAlertView alloc] initWithTitle:@"提示" message:result delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [_resultAlert show];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex==0) {
        NSLog(@"取消");
    }
    else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)textViewDidEndEditing:(UITextView *)textView {
    if (textView.text.length<1) {
        textView.text = @"请输入事件描述：";
        //textView.alpha=0.7;
        textView.textColor=[UIColor grayColor];
    }
}

- (IBAction)popCityListBtn:(UIButton *)btn {
    __weak typeof(self) weakSelf=self;
    _citypop=[[CityDirectionController alloc] init];
    _citypop.currentModel = _currentModel;
    _citypop.modalPresentationStyle=UIModalPresentationPopover;
    _citypop.popoverPresentationController.sourceView=btn;
    _citypop.popoverPresentationController.delegate=self;
    _citypop.popoverPresentationController.sourceRect=CGRectMake(140, 110, 0, 0);
    _citypop.popoverPresentationController.permittedArrowDirections=NO;
    _citypop.LineBlock = ^(NSString *directionDesStr, NSInteger roadDirection) {
        _directionUID = [NSString stringWithFormat:@"%ld",(long)roadDirection];
        weakSelf.carDirectorTF.text = directionDesStr;
      
    };
    [self presentViewController:_citypop animated:YES completion:nil];
}

- (void)setUpKOrLK {
    if ([_currentModel.RoadUID isEqualToString:@"8dd13d88-cb02-4471-876b-1dfe39419ee6"]) {
        UILabel *label1 = [[UILabel alloc] init];
        label1.text = @"K";
        label1.frame = CGRectMake(0, 5, 30, 40);
        _BeginPirTF.leftView     = label1;
        _BeginPirTF.leftViewMode = UITextFieldViewModeAlways;
    }else {
        UILabel *label1 = [[UILabel alloc] init];
        label1.text = @"LK";
        label1.frame = CGRectMake(0, 5, 30, 40);
        _BeginPirTF.leftView     = label1;
        _BeginPirTF.leftViewMode = UITextFieldViewModeAlways;
    }
}

-(void)request {
    RequestHelper *requestHelper=[[RequestHelper alloc] init];
    RequestGinsengModel *getCurrentEventModel=[[RequestGinsengModel alloc] init];
    getCurrentEventModel.URL=GetEventDataURL;
    getCurrentEventModel.DataValue = [self dataValueJson];
    getCurrentEventModel.UpdatedTime=@"2012-01-12 12:00:00";
    getCurrentEventModel.SystemCode=@"GuangleHighway";
    getCurrentEventModel.MethodName=@"ReportOtherEventBaseDetailInfo";
    [requestHelper RequestGinsengModel:getCurrentEventModel andPushController:self];
//    requestHelper.block=^(RequestOutginseng *requestOutginseng,id dataValueModel){
//        
//        NSLog(@"%@",dataValueModel);
//        self.code=[requestOutginseng.Code integerValue];
//        if (self.code==001) {
//            [SVProgressHUD showSuccessWithStatus:@"上报成功"];
//            [self.navigationController popViewControllerAnimated:YES];
//        }
//    };
//    [self requestTestUpdateImage:getCurrentEventModel Image:_imageArray];
}

-(void)requestTestUpdateImage:(RequestGinsengModel *)RequestGinseng Image:(NSArray *)LoadImages {
    [SVProgressHUD showWithStatus:@"正在上传,请稍后......"];
    
    NSDictionary *dic=[[NSDictionary alloc] init];
    dic = @{@"methodName":RequestGinseng.MethodName,@"updatedtime":RequestGinseng.UpdatedTime,@"systemcode":DefaultSystemCode,@"DataValue":RequestGinseng.DataValue};
    NSMutableArray *images = [[NSMutableArray alloc] init];
    [images addObjectsFromArray:LoadImages];
    
    //    if (LoadImages.count != 0 ) {
    [BCNetAPIClient PostVideosAndImages:GetEventDataURL parameters:dic imageArray:images videoArray:_videoUrl.absoluteString success:^(id responseObjecet) {
        [SVProgressHUD showSuccessWithStatus:@"上报成功"];
        [self.navigationController popViewControllerAnimated:YES];
    } failure:^(NSError *error) {
        [SVProgressHUD showSuccessWithStatus:@"上报失败"];
        [self.navigationController popViewControllerAnimated:YES];
    }];
}

- (IBAction)MapPoint:(UIButton *)sender {
    [self.navigationController pushViewController:_map animated:YES];
}

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
    return UIModalPresentationNone;
}

-(NSString *)dataValueJson {
    if (!_info.Latitude&&!_info.Longitude) {
        NSArray *arr=[[TableOperation shareInstance]  getePirNoTableOfRow:[@"K" stringByAppendingString:self.BeginPirTF.text]];
        for (PileInfo *pir in arr) {
            NSLog(@"%f,%f",pir.Latitude,pir.Longitude);
            _info.Latitude=pir.Latitude;
            _info.Longitude=pir.Longitude;
        }
    }
    NSString *k=@"K";
    _info.BeginPile=[k stringByAppendingString:self.BeginPirTF.text];
    _info.BeginPileDistance = [_DistanceTF.text integerValue];
    
    _info.RoadDerection     = _directionUID;
    _info.RoadDerectionName = _carDirectorTF.text;
    _info.RoadUID           = _currentModel.RoadUID;
    _info.IncidentDetail    = _DescriptionTV.text;
    _info.IncidentSource    = @"2";
    NSLog(@"%@",_DescriptionTV.text);
    
    NSMutableDictionary *dic=_info.mj_keyValues;
    NSString *str=[dic mj_JSONString];
    
    ParModel *model=[[ParModel alloc] init];
    model.key=@"EventBaseInfo";
    model.value=str;
    
    NSMutableDictionary *jsonDic=model.mj_keyValues;
    NSString *json=[jsonDic mj_JSONString];
    
    NSString *strl=@"[";
    NSString *temp=[strl stringByAppendingString:json];
    NSString *str1r=@"]";
    NSString *JsonString=[temp stringByAppendingString:str1r];
    
    return JsonString;
}
- (void)report {
    NSLog(@"%f",_info.Latitude);
    NSLog(@"%f",_info.Longitude);
    if (!_info.Latitude&&!_info.Longitude&&stringIsEmpty(_BeginPirTF.text)) {
        [_PromptUtil alert:@"开始桩号不能为空"];
        return;
    }
    if (stringIsEmpty(_DistanceTF.text)) {
        _DistanceTF.text=@"0";
    }
    if ([_DistanceTF.text intValue]>999) {
        [_PromptUtil alert:@"桩距离不能大于999"];
        return;
    }
    if (stringIsEmpty(_carDirectorTF.text)) {
        [_PromptUtil alert:@"行车方向不能为空"];
        return;
    }
    if (stringIsEmpty(_DescriptionTV.text)) {
        [_PromptUtil alert:@"事件描述不能为空"];
        return;
    }
    if ([_DescriptionTV.text isEqualToString:@"请输入事件描述："])
    {
        [_PromptUtil alert:@"请输入事件描述"];
        return;
    }
    
    if (_DescriptionTV.text.length > 1000) {
        [_PromptUtil alert:@"事件描述不能超过1000字"];
        return;
    }
    
    if ([self isNumber:_BeginPirTF.text]) {
        [_PromptUtil alert:@"请输入整形数字开始桩号"];
        return;
    }
    int res=[_BeginPirTF.text intValue];
    if (res>269&&[_LineTF.text isEqualToString:@"主  线"]) {
        [_PromptUtil alert:@"主线桩号不能大于269"];
        return;
    }
    if (res>32&&[_LineTF.text isEqualToString:@"韶赣北连线"]) {
        [_PromptUtil alert:@"韶赣北连线桩号不能大于32"];
        return;
    }
    if (res>3&&[_LineTF.text isEqualToString:@"韶赣南连线"]) {
        [_PromptUtil alert:@"韶赣南连线桩号不能大于3"];
        return;
    }
    if ([self isNumber:_DistanceTF.text]) {
        [_PromptUtil alert:@"请输入整形数字开始桩距离"];
        return;
    }
    [self request];
}

- (IBAction)LineBtn:(UIButton *)sender { //(130, 100, 0, 0)
    __weak typeof(self) weakSelf=self;
    _lineVC = [[OtherEventMainLineViewController alloc] init];
    _lineVC.modalPresentationStyle = UIModalPresentationPopover;
    _lineVC.LineBlock = ^(NSString *lineStr, HighwayMergeRoadRecordModel *model) {
        weakSelf.LineTF.text  = lineStr;
        weakSelf.currentModel = model;
        [weakSelf configDirectionText];
          [weakSelf setUpKOrLK];
    };
    _lineVC.popoverPresentationController.sourceView = sender;
    _lineVC.popoverPresentationController.delegate   = self;
    _lineVC.popoverPresentationController.sourceRect = CGRectMake(90, 5, 100, 210);
    _lineVC.popoverPresentationController.permittedArrowDirections=NO;
    [self presentViewController:_lineVC animated:YES completion:nil];
}

- (void) configDirectionText {
    HighWayRoadRecordDirectionInfoModel *directionModel= _currentModel.highWayRoadDirectionList[0];
    _carDirectorTF.text = directionModel.DirectionDescription;
    _directionUID       = directionModel.RoadDirection;
}

- (IBAction)chooseImage:(UIButton *)sender {
    if (_imageArray.count >=5) {
        [SVProgressHUD showErrorWithStatus:@"不能上传超过5张图片"];
        return;
    }
    
    AJPhotoPickerViewController *picker = [[AJPhotoPickerViewController alloc] init];
    picker.maximumNumberOfSelection = 5 - _imageArray.count;
    picker.multipleSelection        = YES;
    picker.assetsFilter             = [ALAssetsFilter allPhotos];
    picker.showEmptyGroups          = YES;
    picker.delegate                 = self;
    picker.selectionFilter          = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
        return YES;
    }];
    [self presentViewController:picker animated:YES completion:nil];

}

#pragma mark - BoPhotoPickerProtocol
- (void)photoPickerDidCancel:(AJPhotoPickerViewController *)picker {
    [picker dismissViewControllerAnimated:YES completion:nil];
}

- (void)photoPicker:(AJPhotoPickerViewController *)picker didSelectAssets:(NSArray *)assets {
    [self.photos addObjectsFromArray:assets];
        CGFloat x = 0;
        CGRect frame = CGRectMake(0, 0, 125, 125);
//    self.imagesScrollView.hidden = NO;
       self.scrollView.hidden = NO;
        _imageArray = [[NSMutableArray alloc] init];
        for (int i = 0 ; i < self.photos.count; i++) {
            ALAsset *asset = self.photos[i];
            UIImage *tempImg = [UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage];
            frame.origin.x = x;
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
            [imageView setContentMode:UIViewContentModeScaleAspectFill];
            imageView.clipsToBounds = YES;
            imageView.image = tempImg;
            imageView.tag = i;
            imageView.userInteractionEnabled = YES;
            [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showBig:)]];
            [_imageArray addObject:imageView.image];
            [self.scrollView addSubview:imageView];
            x += frame.size.width+5;
    }
    self.scrollView.contentSize = CGSizeMake(125 * _imageArray.count + (_imageArray.count - 1) * 5, 0);
    
    [picker dismissViewControllerAnimated:NO completion:nil];
}

- (void)showBig:(UITapGestureRecognizer *)sender {
    NSInteger index = sender.view.tag;
    AJPhotoBrowserViewController *photoBrowserViewController = [[AJPhotoBrowserViewController alloc] initWithPhotos:self.photos index:index];
    photoBrowserViewController.delegate = self;
    [self presentViewController:photoBrowserViewController animated:YES completion:nil];
}
- (void)photoBrowser:(AJPhotoBrowserViewController *)vc didDonePhotos:(NSArray *)photos {
//    dispatch_get_main_queue()
    dispatch_async(dispatch_get_main_queue(), ^{
        [self removeDeleteImages];
        [self configImages];
    });
    [vc dismissViewControllerAnimated:YES completion:^{
//        [self removeDeleteImages];
//        [self configImages];
    }];
    
}
- (void)photoBrowser:(AJPhotoBrowserViewController *)vc deleteWithIndex:(NSInteger)index {
    
    [self.imageArray removeObjectAtIndex:index];
    [self.photos removeObjectAtIndex:index];
}

- (void)removeDeleteImages {
    for (UIImageView *imageV in self.scrollView.subviews) {
        [imageV removeFromSuperview];
    }
}
- (void) configImages {
    CGFloat x = 0;
    CGRect frame = CGRectMake(0, 0, 125, 125);
    //    self.imagesScrollView.hidden = NO;
    self.scrollView.hidden = NO;

    for (int i = 0; i < _imageArray.count; i ++) {
        frame.origin.x = x;
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
        [imageView setContentMode:UIViewContentModeScaleAspectFill];
        imageView.clipsToBounds = YES;
        imageView.image = _imageArray[i];
        imageView.tag = i;
        imageView.userInteractionEnabled = YES;
        [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showBig:)]];
        [self.scrollView addSubview:imageView];
        x += frame.size.width+5;
    }
     self.scrollView.contentSize = CGSizeMake(125 * _imageArray.count + (_imageArray.count - 1) * 5, 0);
}


- (void)photoPickerTapCameraAction:(AJPhotoPickerViewController *)picker {
    
    [SVProgressHUD showErrorWithStatus:@"该功能有待完善"];
    return;
    
//    [self checkCameraAvailability:^(BOOL auth) {
//        if (!auth) {
//            NSLog(@"没有访问相机权限");
//            return;
//        }
//        [picker dismissViewControllerAnimated:NO completion:nil];
//        UIImagePickerController *cameraUI = [UIImagePickerController new];
//        cameraUI.allowsEditing   = NO;
//        cameraUI.delegate        = self;
//        cameraUI.sourceType      = UIImagePickerControllerSourceTypeCamera;
//        cameraUI.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
//        [self presentViewController: cameraUI animated: YES completion:nil];
//    }];
}



- (void)checkCameraAvailability:(void (^)(BOOL auth))block {
    BOOL status = NO;
    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if(authStatus == AVAuthorizationStatusAuthorized) {
        status = YES;
    } else if (authStatus == AVAuthorizationStatusDenied) {
        status = NO;
    } else if (authStatus == AVAuthorizationStatusRestricted) {
        status = NO;
    } else if (authStatus == AVAuthorizationStatusNotDetermined) {
        [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
            if(granted){
                if (block) {
                    block(granted);
                }
            } else {
                if (block) {
                    block(granted);
                }
            }
        }];
        return;
    }
    if (block) {
        block(status);
    }
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
    UIImage *originalImage;
    if (CFStringCompare((CFStringRef) mediaType,kUTTypeImage, 0)== kCFCompareEqualTo) {
        originalImage = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];
    }
    
    if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
        UIImageWriteToSavedPhotosAlbum(originalImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
    }else {
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}
- (void)image:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo {
    if (!error) {
//        NSLog(@"保存到相册成功");
        AJPhotoPickerViewController *picker = [[AJPhotoPickerViewController alloc] init];
        picker.maximumNumberOfSelection = 5;
        picker.multipleSelection        = YES;
        picker.assetsFilter             = [ALAssetsFilter allPhotos];
        picker.showEmptyGroups          = YES;
        picker.delegate                 = self;
        picker.selectionFilter          = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
            return YES;
        }];
        [self dismissViewControllerAnimated:NO completion:nil];
        [self presentViewController:picker animated:NO completion:nil];
    }else{
//        NSLog(@"保存到相册出错%@", error);
    }
}

- (IBAction)videoBtnClick:(id)sender {
     [self cameraBtnClick];
}

- (void) cameraBtnClick {
//    NSLog(@"这个照相机哦");
    
    LittleVideoViewController *vc = [[LittleVideoViewController alloc] init];
    vc.delegate = self;
    [self.navigationController presentViewController:vc animated:YES completion:nil];
    
}
// *********** - 播放小视频 - *************
#pragma mark -littleVideoDelegate
- (void)finishLittleVideoViewControllerCapture:(NSURL *)filePath {
    _videoUrl = filePath;
    [self crreatPlayViedeo:filePath];
    
}
- (void) crreatPlayViedeo:(NSURL *)videoUrl {
    self.videoView.hidden = NO;
    _playItem = [AVPlayerItem playerItemWithURL:videoUrl];
    _player = [AVPlayer playerWithPlayerItem:_playItem];
    _playerLayer =[AVPlayerLayer playerLayerWithPlayer:_player];
    _playerLayer.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 16, 200);
    _playerLayer.videoGravity=AVLayerVideoGravityResizeAspectFill;//视频填充模式
    [self.videoView.layer addSublayer:_playerLayer];
    [_player play];

}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [_player pause];
    _player = nil;
    [_sheet hiddenSheet];
}

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    return NO;
}

@end
